package cn.wolfcode.luowowo.common.util;

import cn.wolfcode.luowowo.common.exception.LogicException;

public class AssertUtil {

    /**
     * 判断是值是否为空,如果为空,抛出异常
     * @param value
     * @param msg
     */
    public static void hasLength(String value,String msg){
        if(value == null || "".equals(value.trim())){
            throw  new LogicException(msg);
        }
    }

    /**
     * 判断两个值是否相等,如果不相等,抛出异常
     * @param value1
     * @param value2
     * @param msg
     */
    public static void isEquals(String value1,String value2,String msg){
        if(value1 == null || value2 == null){
            throw  new LogicException("方法参数不能为null");
        }

        if(!value1.equals(value2)){
            throw  new LogicException(msg);
        }
    }
}
